GdPicture.NET.14.API
GdPicture14 Namespace / GdPicturePDF Class / MergeDocuments Method / MergeDocuments(String[],String) Method
An array of strings defining the file paths of all the PDF documents you want to merge.
The file path of the destination PDF document.

Please ensure that the destination file path differs from all source file paths.

Example





In This Topic
MergeDocuments(String[],String) Method
In This Topic
Merge several PDF documents according to their file paths stored in the input parameter. All pages of the source documents are cloned one by one to the destination document in that order how they are stored in the input parameter. The resulting PDF document is saved to a file path you have specified. If the specified file already exists, it will be overwritten.

If the first PDF document in the list (specified by the first object in the input parameter) is PDF/A compliant, the resulting document will also be PDF/A compliant. The conformance level and version of the merged document will be PDF/A-1b regardless of the original conformance of the first source document.

Just to inform you, that the toolkit offers the adaptive file caching mechanism to significantly reduce memory usage while merging large documents. The feature is available in both 32-bit and 64-bit mode by default.

Syntax
'Declaration
 
Public Overloads Function MergeDocuments( _
   ByVal SrcDocPath() As String, _
   ByVal DstDoc As String _
) As GdPictureStatus
public GdPictureStatus MergeDocuments( 
   string[] SrcDocPath,
   string DstDoc
)
public function MergeDocuments( 
    SrcDocPath: Stringarray of;
    DstDoc: String
): GdPictureStatus; 
public function MergeDocuments( 
   SrcDocPath : String[],
   DstDoc : String
) : GdPictureStatus;
public: GdPictureStatus MergeDocuments( 
   string*[]* SrcDocPath,
   string* DstDoc
) 
public:
GdPictureStatus MergeDocuments( 
   array<String^>^ SrcDocPath,
   String^ DstDoc
) 

Parameters

SrcDocPath
An array of strings defining the file paths of all the PDF documents you want to merge.
DstDoc
The file path of the destination PDF document.

Please ensure that the destination file path differs from all source file paths.

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.

We strongly recommend always checking this status first.

Remarks
This method is only allowed for use with non-encrypted documents.

Be aware that you have to specify a full file path for the destination document with the correct file extension, which is "pdf". Likewise it is required, that the destination file path differs from all source file paths.

You don't need to load any document within the GdPicturePDF object you are going to use. You can simply use it as an empty wrapper object, as it is shown in the example below.

This method requires the Document Editor component to run.

Example
How to merge 3 PDF documents using their file paths into a PDF document specified by its file path.
Dim arPDF As String() = New String(2) {}
arPDF(0) = "test1.pdf"
arPDF(1) = "test2.pdf"
arPDF(2) = "test3.pdf"
Using gdpicturePDF As New GdPicturePDF()
    Dim status As GdPictureStatus = gdpicturePDF.MergeDocuments(arPDF, "test_merged.pdf")
    If status = GdPictureStatus.OK Then
        MessageBox.Show("All documents have been successfully merged.", "Example: MergeDocuments")
    Else
        MessageBox.Show("The MergeDocuments() method has failed with the status: " + status.ToString(), "Example: MergeDocuments")
    End If
End Using
string[] arPDF = new string[3];
arPDF[0] = "test1.pdf";
arPDF[1] = "test2.pdf";
arPDF[2] = "test3.pdf";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
    GdPictureStatus status = gdpicturePDF.MergeDocuments(arPDF, "test_merged.pdf");
    if (status == GdPictureStatus.OK)
    {
        MessageBox.Show("All documents have been successfully merged.", "Example: MergeDocuments");
    }
    else
    {
        MessageBox.Show("The MergeDocuments() method has failed with the status: " + status.ToString(), "Example: MergeDocuments");
    }
}
See Also